'use strict';
function average(arr){
    let sum=arr.reduce(function(m,n){
        return m+n;
    },0);
    let result = sum/arr.length;
    return result;
}

var even_group_calculate_average = function(collection){
    let arr=collection.filter(function(element,index,collection){
        return index%2!==0;
    });
    let arr1 = arr.filter(function(element){
        return element%2===0;
    });


    let cct1=[],cct2=[],cct3=[],result=[];
    let answer1,answer2,answer3;
    for(let item of arr1){
        if(item<10){
            cct1.push(item);
            
        }
         if(item>=10&&item<100){
            cct2.push(item);
            
        }
         if(item>=100&&item<1000){
            cct3.push(item);
           
        }
        
    }
    console.log(cct1);
    console.log(cct2);
    console.log(cct3);
    answer1=average(cct1);
    answer2=average(cct2); 
    answer3=average(cct3);
    result.push(answer1,answer2,answer3);
    console.log(result);
    return result;

};
even_group_calculate_average([1, 2, 3, 4, 5, 6, 12, 454, 324, 21, 45, 644, 34, 56, 345, 570, 8, 4, 14]);
module.exports = even_group_calculate_average;

// function group_fen(array){
//     let obj = {} ;
//     for(let item of array){
//         let key =item.toString().length ;
//         if(!obj[key]){
//             obj[key] = [] ;
//             obj[key].push(item) ;
//         }else{
//             obj[key].push(item) ;
//         }
//     }
//     return obj ;
// }
// console.log(group_fen([1, 2, 3, 4, 5, 6, 12, 454, 324, 21, 45, 644, 34, 56, 345, 570, 8, 4, 14]));